package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.ScheduleRecordDao;
import cn.topevery.garden.entity.po.Extent;
import cn.topevery.garden.entity.po.ScheduleRecord;
import cn.topevery.garden.entity.query.ScheduleRecordQuery;
import cn.topevery.garden.entity.vo.FacilitiesPageVO;
import cn.topevery.garden.entity.vo.ScheduleRecordVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 排班记录表
 *
 * @author code-generate
 * @date 2021-12-28
 */
@Service
public class ScheduleRecordLogic extends BaseLogic<ScheduleRecord> {
    @Autowired
    ScheduleRecordDao scheduleRecordDao;

    @Override
    public BaseEntityDao<ScheduleRecord, Integer> getDao() {
        return scheduleRecordDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<ScheduleRecordVO> listPage(ScheduleRecordQuery query) {
        return scheduleRecordDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        scheduleRecordDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param scheduleRecord 实体
     */
    public void saveOrUpdate(String userId, ScheduleRecord scheduleRecord){
        scheduleRecordDao.saveOrUpdate(userId,scheduleRecord);
    }

    /**
         * 根据自定义列值来获取对象
         */
    public ScheduleRecord getEntityByColumn(String key, String value) {
        return scheduleRecordDao.getEntityByColumn(key, value);
    }

    public void createScheduleRecord() {
         scheduleRecordDao.createScheduleRecord();
    }

    public List<ScheduleRecordVO> statisticsData(ScheduleRecordQuery query) {
        return scheduleRecordDao.statisticsData(query);
    }

    public Map getExtentWorkInfo(ScheduleRecordQuery query) {
        Map map=null;
        if(query.getObjectTypeId()!=null&& query.getObjectTypeId().equals(1)){
            map=scheduleRecordDao.getExtentPeopleWorkInfo(query);
        }
        else{
            map=scheduleRecordDao.getExtentCarWorkInfo(query);
        }
        return map;
    }

    public List<Map<String,Object>> getExtentWorkObjList(ScheduleRecordQuery query) {
        List<Map<String,Object>> maps=null;
        if(query.getObjectTypeId()!=null&&query.getObjectTypeId().equals(1)){
            maps=scheduleRecordDao.getExtentWorkPeopleList(query);
        }
        else{
            maps=scheduleRecordDao.getExtentWorkCarList(query);
        }
        return maps;
    }

    public Map getExtentWorkPersonAndCarInfo(ScheduleRecordQuery query) {
        Map map=null;
            map=scheduleRecordDao.getExtentWorkPersonAndCarInfo(query);
        return map;
    }

    public List<Map<String,Object>> getObjShiftWorkInfo(ScheduleRecordQuery query) {
        List<Map<String,Object>> maps=null;
        if(query.getObjectTypeId()!=null) {
            if (query.getObjectTypeId().equals(1)) {
                maps = scheduleRecordDao.getPersonShiftWorkInfo(query);
            }
            else if(query.getObjectTypeId().equals(2)){
                maps = scheduleRecordDao.getCarShiftWorkInfo(query);
            }
        }
        return maps;
    }

    public List<Map<String,Object>> getObjTaskInfo(ScheduleRecordQuery query) {
        List<Map<String,Object>> maps=null;
        if(query.getObjectTypeId()!=null){
            maps=scheduleRecordDao.getTaskInfo(query);
        }
        return maps;
    }

    public void insertStatusPerson() {
        scheduleRecordDao.insertStatusPerson();
    }

    public void insertStatusCar() {
        scheduleRecordDao.insertStatusCar();
    }

    public List<Extent> getObjWorkExtent(ScheduleRecordQuery query) {
       return scheduleRecordDao.getObjWorkExtent(query);
    }

    public List<FacilitiesPageVO> getObjWorkTaskFacilities(ScheduleRecordQuery query) {
        return scheduleRecordDao.getObjWorkTaskFacilities(query);
    }
}
